package com.atguigu.gmall.pay.controller;

import com.alipay.api.AlipayApiException;
import com.atguigu.gmall.pay.service.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/9/15 19:43
 */
@RestController
@RequestMapping("/api/payment")
public class PayController {
    @Autowired
    private PayService payService;
    // 支付接口 /api/payment/alipay/submit/1174433063782842368
    @GetMapping(value = "/alipay/submit/{orderId}",produces = "text/html")
    public String alipaySubmit(@PathVariable("orderId") Long orderId) throws AlipayApiException {
        // 调用支付宝支付接口，生成支付链接
        String payUrl=payService.alipaySubmit(orderId);
        return payUrl;
    }
}
